const Router = require('@koa/router');
const router = new Router();
const WebSocketManager = require('../service/common/websocket-util');
const wss = WebSocketManager.getInstance();
//测试websocket广播
router.get('/websocket/broadcast', async (ctx, next) => {
	wss.broadcast('全体公告：现在是广播所有人通知!');
});

//测试websocket发送群组消息
router.get('/websocket/sendToGroup', async (ctx, next) => {
	wss.sendToGroup([1, 2], '群组公告：现在是群组通知!');
});

//测试websocket发送个人消息
router.get('/websocket/sendMessage', async (ctx, next) => {
	wss.sendMessage(1, '个人公告：现在是个人通知!');
});

module.exports = router;
